package com.zhaojy.poc.controller;

import com.zhaojy.poc.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by zhaojiuyang1 on 16/3/12.
 */
@Controller
@RequestMapping(value = "car")
public class CarController {
    @Autowired
    private CarService carService;

    @RequestMapping(value = "forward" ,method = RequestMethod.GET)
    @ResponseBody
    public Object forward(){
        carService.forward();
        return "success";
    }
    @RequestMapping(value = "backward" ,method = RequestMethod.GET)
    @ResponseBody
    public Object backward(){
        carService.backward();
        return "success";
    }
    @RequestMapping(value = "left" ,method = RequestMethod.GET)
    @ResponseBody
    public Object left(){
        carService.left();
        return "success";
    }
    @RequestMapping(value = "right" ,method = RequestMethod.GET)
    @ResponseBody
    public Object right(){
        carService.right();
        return "success";
    }

    @RequestMapping(value = "stop" ,method = RequestMethod.GET)
    @ResponseBody
    public Object stop(){
        carService.stop();
        return "success";
    }

}
